function addCarouselAnimation() {
  console.log('鎵цhome.js');
  $('.carousel-home').slick({
    lazyLoad: 'progressive',
    autoplay: true,
    cssEase: 'linear',
    speed: 500,
    autoplaySpeed: 5000,
  })
  $('.slick-active').find('span').addClass('animated');

  var $videos = $('.carousel-home video');
  $('.carousel-home').on('afterChange', function(event, slick, currentSlide) {
    for (var i = 0; i < $videos.length; i++) {
      stopVideoPlaying($($videos[i]), false)
    }
    $('.slick-active').find('span').addClass('animated');
    $('.slick-active').siblings('.slick-slide').find('span').removeClass('animated')
  })

  var $videoOverlay = $('#home-campaign-video-overlay')
  var videoElement = $videoOverlay.find('video')[0]
  $('#home-campaign-video').click(function(event) {
    event.preventDefault()
    $videoOverlay.addClass('active')
    videoElement.play()
  })
  $videoOverlay.find('.close').click(function() {
    videoElement.pause()
  })
  $(document).keydown(function(event) {
    if (videoElement && event.keyCode == 27) { // esc
      videoElement.pause()
    }
  })

  $('.carousel-libra').slick({
    lazyLoad: 'progressive',
    autoplay: true,
    cssEase: 'linear',
    speed: 500,
    autoplaySpeed: 5000,
    dots: true,
    prevArrow: $('.slick-prev'),
    nextArrow: $('.slick-next')
  })

  $(window).load(function () {
    var carouselVideo = $('.carousel-video');
    var carouselImage = $('.carousel-image')[0];
    var mobileCarouselImage = $('.mobile-carousel-image')[0];
    if (window.innerWidth > 640) {
      carouselVideo.css("height", carouselImage.height);
      carouselVideo.css("width", "auto");
    } else {
      carouselVideo.css("height", mobileCarouselImage.height);
      carouselVideo.css("width", "auto");
    }
  })

  $('.play-btn').click(function(e) {
    var $this = $(this)
    var $video = $this.prev()
    if(window.innerWidth > 640) {
      $video = $this.prev().prev()
    }
    $video[0].play()
    $this.addClass('hidden')
    e.stopPropagation()
    e.preventDefault()
  })

  function stopVideoPlaying($video, ended) {
    if (ended) {
      $video.removeClass('playing')
      $video[0].currentTime = 0
      $video[0].pause()
    } else {
      $video[0].pause()
    }
    $video.next().removeClass('hidden')
    $video.next().next().removeClass('hidden')
  }

  var $videos = $('.carousel-home video')
  $videos.click(function() {
    stopVideoPlaying($(this))
  })
  $videos.on('ended', function() {
    stopVideoPlaying($(this), true)
  })
}